define(['zepto', 'butterfly/view','../../bsl',
    'text!./events.html'
], function($, View, bsl, EventS) {
    var me = null;

    var view = View.extend({
        events: {

            // ！！！！ 由于 引入 touch.js 后，tap事件会变成双击，所以 本页面内不能使用tap，用click代替。
            "tap #openDoc" : "openDoc",
            "tap #back" : "back",

      
        },
        render: function() {
            me = this;
        },

        onShow: function() {
            this.domcoentload();

            // 绑定自定义事件 滑动切换日历等           


        },
                domcoentload:function(){
                if(window.plus){
            if(document.body){
                outLine( currentTimeString()+" HTML5 Plus已准备" );
            }else{
                document.addEventListener("DOMContentLoaded",function(){
                    outLine( currentTimeString()+" HTML5 Plus已准备" );
                },false);
            }
        }else{
            document.addEventListener("plusready",function(){
                outLine( currentTimeString()+" HTML5 Plus已准备" );
            }, false );
        }
        document.addEventListener("pause",function(){
            outLine( currentTimeString()+" 应用从前台切换到后台" );
        }, false );
        document.addEventListener("resume",function(){
            outLine( currentTimeString()+" 应用从后台切换到前台" );
        }, false );
        document.addEventListener("netchange",function(){
            var types = {};
            types[plus.networkinfo.CONNECTION_UNKNOW] = "未知";
            types[plus.networkinfo.CONNECTION_NONE] = "未连接网络";
            types[plus.networkinfo.CONNECTION_ETHERNET] = "有线网络";
            types[plus.networkinfo.CONNECTION_WIFI] = "WiFi网络";
            types[plus.networkinfo.CONNECTION_CELL2G] = "2G蜂窝网络";
            types[plus.networkinfo.CONNECTION_CELL3G] = "3G蜂窝网络";
            types[plus.networkinfo.CONNECTION_CELL4G] = "4G蜂窝网络";
            outLine( currentTimeString()+" 切换网络："+types[plus.networkinfo.getCurrentType()] );
        }, false );
        document.addEventListener("newintent",function(){
            outLine( currentTimeString()+" 从第三方应用启动："+plus.runtime.arguments );
        }, false );},
   currentTimeString:function (){
            var d = new Date();
            return d.getHours()+":"+d.getMinutes()+":"+d.getSeconds()+"."+d.getMilliseconds()+" - ";
        },
        back : function(e){
            window.history.go(-1);
        },
        openDoc:function(){
             window.butterfly.navigate('com.no5.cordovademo/doc/events', {
                trigger: true
            });


        },
       
        
             
            });
    return view;
});
